﻿using Edu.Localization.Edu;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;

namespace Edu.Permissions
{
    public class EduPermissionDefinitionProvider : PermissionDefinitionProvider
    {
        public override void Define(IPermissionDefinitionContext context)
        {
            var achievementGroup = context.AddGroup(AchievementPermissions.GroupName, L("成就配置"));

            var achievementPermission = achievementGroup.AddPermission(AchievementPermissions.Default, L("成就配置管理"));
            achievementPermission.AddChild(AchievementPermissions.Create, L("成就配置创建"));
            achievementPermission.AddChild(AchievementPermissions.Update, L("成就配置修改"));
            achievementPermission.AddChild(AchievementPermissions.Delete, L("成就配置删除"));
            achievementPermission.AddChild(AchievementPermissions.ManagePermissions, L("成就配置管理权限"));



            var userAchievementGroup = context.AddGroup(UserAchievementPermissions.GroupName, L("用户成就"));

            var userAchievementPermission = userAchievementGroup.AddPermission(UserAchievementPermissions.Default, L("用户成就管理"));
            userAchievementPermission.AddChild(UserAchievementPermissions.Create, L("用户成就创建"));
            userAchievementPermission.AddChild(UserAchievementPermissions.Update, L("用户成就修改"));
            userAchievementPermission.AddChild(UserAchievementPermissions.Delete, L("用户成就删除"));
            userAchievementPermission.AddChild(UserAchievementPermissions.ManagePermissions, L("用户成就管理权限"));


            var studyTaskGroup = context.AddGroup(StudyTaskPermissions.GroupName, L("学习任务"));
            var studyTaskPermission = studyTaskGroup.AddPermission(StudyTaskPermissions.Default, L("学习任务管理"));
            studyTaskPermission.AddChild(StudyTaskPermissions.Create, L("学习任务创建"));
            studyTaskPermission.AddChild(StudyTaskPermissions.Update, L("学习任务修改"));
            studyTaskPermission.AddChild(StudyTaskPermissions.Delete, L("学习任务删除"));
            studyTaskPermission.AddChild(StudyTaskPermissions.ManagePermissions, L("学习任务管理权限"));

        }

        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<EduResource>(name);
        }
    }
}
